package factory;

import service.IPaymentStrategy;
import service.impl.AlipayStrategy;
import service.impl.CreditCardStrategy;
import service.impl.WechatPayStrategy;

/**
 * 支付策略工厂
 */
public class PaymentStrategyFactory {
    public enum PaymentType {
        ALIPAY, WECHAT, CREDIT_CARD
    }

    public static IPaymentStrategy createStrategy(PaymentType type, String... params) {
        return switch (type) {
            case ALIPAY -> new AlipayStrategy(params[0]);
            case WECHAT -> new WechatPayStrategy(params[0]);
            case CREDIT_CARD -> new CreditCardStrategy(params[0], params[1]);
        };
    }
}
